﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessLayer;
using System.Web.Security;
using System.Windows.Forms;

namespace Design
{
    public partial class WebForm8 : System.Web.UI.Page
    {
        MembershipUser user;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (User.Identity.IsAuthenticated)
            {
                user = Membership.GetUser(User.Identity.Name);

                if (!IsPostBack)
                {
                    txtemail.Text = user.Email;
                }

                txtusername.Text = user.UserName;
                txtdatecreated.Text = user.CreationDate.ToString();
            }
            else
            {
                Response.Redirect("~/Login.aspx");
                txtusername.Text = "";
                txtdatecreated.Text = "";
                txtemail.Text = "";

            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                user.Email = txtemail.Text;
                Membership.UpdateUser(user);

                MessageBox.Show("Are You Sure You Want To Update", "Update", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            }
            catch
            {
                MessageBox.Show("Invalid Details", "Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

    }
}